package cn.itcast.com.Thread;
//Container表示蒸笼，即容量唯一
public class Container {
    //该成员变量表示一个包子
    private Food food;

    //该方法只被生产者调用,只运行在生产者线程
    public void setFood(Food food) {
        this.food = food;
        System.out.println(Thread.currentThread().getName()+"做了一个包子"+this.food);

    }
    //该方法被消费者调用，只运行在消费者线程
    public void eatFodd(){
        System.out.println(Thread.currentThread().getName()+"吃了一个包子"+this.food);
        this.food = null;
    }

    //让当前的使用者知道当前蒸笼是否有包子
    public boolean isEmpty(){
        return food == null;
    }
}

class Food{
    private String name;

    private double price;

    public Food(String name, double price) {
        this.name = name;
        this.price = price;
    }

    @Override
    public String toString() {
        return "Food{" +
                "name='" + name + '\'' +
                ", price=" + price +
                '}';
    }
}